package com.youbug.mall.member_ums.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.member_ums.entity.UmsMemberLevel;
import com.youbug.mall.member_ums.service.IUmsMemberLevelService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 会员等级 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-04-14
 */
@RestController
@RequestMapping("/umsMemberLevel")
public class UmsMemberLevelController {

    @Autowired
    private IUmsMemberLevelService umsMemberLevelService;  // 13 G039

    @PostMapping("/getUmsMemberLevelPage")
    public R<IPage<UmsMemberLevel>> getUmsMemberLevelPage(@RequestBody QueryVo<UmsMemberLevel> queryVo){

        IPage<UmsMemberLevel> umsMemberLevels = umsMemberLevelService.getUmsMemberLevelPage(queryVo);

        return R.ok(umsMemberLevels);
    }

    @GetMapping("/getUmsMemberLevelById/{id}")
    public R<UmsMemberLevel> getUmsMemberLevelById(@PathVariable Integer id){

        UmsMemberLevel umsMemberLevel = umsMemberLevelService.getById(id);

        return R.ok(umsMemberLevel);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody UmsMemberLevel umsMemberLevel){

        boolean save = umsMemberLevelService.save(umsMemberLevel);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody UmsMemberLevel umsMemberLevel){

        boolean update = umsMemberLevelService.updateById(umsMemberLevel);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = umsMemberLevelService.removeById(id);

        return  R.ok(remove);
    }
}

